library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1     ✔ purrr   0.3.3
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   1.0.0     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
library(maptools)
## Loading required package: sp
## Checking rgeos availability: TRUE
library(sp)
library(mapdata)
map('worldHires','Canada', xlim=c(-141,-53), ylim=c(40,85), col='gray90', fill=TRUE)

df = read.csv('https://raw.githubusercontent.com/bcdunbar/datasets/master/meteorites_subset.csv')
Sys.setenv('MAPBOX_TOKEN' = 'pk.eyJ1Ijoic2FsbHlpbm5pcyIsImEiOiJjazR3eWszdnEwN3B6M250aGt3YnM4aW9yIn0.KQelI9-fKQw9FfAkQRo6jA')
library(readxl)
CadTSF <- read_excel("Canadian Filtered TSFs.xlsx", 
    sheet = "Filtered and Changed")
## New names:
## * `` -> ...4
#View(CadTSF)
library(scales)  #for transparency
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
map('worldHires','Canada', xlim=c(-141,-53), ylim=c(40,85), col='gray90', fill=TRUE)
points(CadTSF$Longitude, CadTSF$Latitude, pch=19, col="red", cex=0.5) 

library(mapproj)
map('worldHires','Canada', xlim=c(-141,-53), ylim=c(40,85), col="grey80", fill=TRUE, projection="gilbert", orientation= c(90,0,225))
lon <- c(-72, -66, -107, -154)  #fake longitude vector
lat <- c(81.7, 64.6, 68.3, 60)  #fake latitude vector
coord <- mapproject(CadTSF$Longitude, CadTSF$Latitude, proj="gilbert", orientation=c(90, 0, 225))  #convert points to projected lat/long
points(coord, pch=20, cex=.8, col="red")  #plot converted points

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
packageVersion('plotly')
## [1] '4.9.0'
library(plotly)

dat <- map_data("world","canada") %>% group_by(group)

p <- plot_mapbox(dat, x = ~long, y = ~lat) %>%
  layout(mapbox = list(zoom = 4,
                       center = list(lat = ~median(lat),
                                     lon = ~median(long))
  ))

p
## No scattermapbox mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
library(plotly)
library(dplyr)

p <- plot_mapbox(mode = 'scattermapbox') %>%
  add_markers(
    data = CadTSF, x = ~Longitude, y = ~Latitude, text= ~Mine, size = 4, color= ~Status, hoverinfo = "text") %>%
 layout( plot_bgcolor = 'white', paper_bgcolor = 'white',
         mapbox = list(zoom = 3,
                       center = list(lat = 60,
                                     lon = -97)
  ))
p